import sys
if __name__ == "__main__":
    friend_pairs = {}
    for row in sys.stdin:
        if row.strip() != '':
            person = row[0]
            friends = list(row[1:].strip())
            for i in range(len(friends)):
                if person not in friend_pairs:
                    pairs_set = []
                    pairs_set.append(friends[i])
                    friend_pairs[person] = pairs_set
                else:
                    friend_pairs[person].append(friends[i])
    # print(dict(friend_pairs))                
    for k in friend_pairs:
        print(k)
        print(friend_pairs[k])                    